<template>
    <div class="card-page">
        <el-row :gutter="12" type="flex">
            <el-col :span="12">
                <el-card shadow="always">
                    <template #header v-if="title">   <span>{{title}}</span> </template>
                    <kv label="数据类型是对象或数组时，子级的类型定义">
                        <el-input v-model="info.items" />
                    </kv>
                    <kv label="属性名">
                        <el-input v-model="info.key" />
                    </kv>
                    <kv label="type">
                        <selector v-model="info.type" enum="ApiParameterTypeEnum" chk="*"/>
                    </kv>
                    <kv label="isList">
                        <selector v-model="info.isList" :data="{true:'是',false:'否','':'全部'}" />
                    </kv>
                    <kv label="可选数据,当 type 是 Radio,Check, 或者 arrayItemType 是Radio,Check 时">
                        <el-input v-model="info.enumData" />
                    </kv>
                    <kv label="enumType">
                        <el-input v-model="info.enumType" />
                    </kv>
                    <kv label="stringType">
                        <selector v-model="info.stringType" enum="ApiParameterStringTypeEnum" chk="*"/>
                    </kv>
                    <kv label="type=object时,引入的类型,apiModel">
                        <ref-object-reference v-model="info.objectReference"></ref-object-reference>
                    </kv>
                    <kv label="默认值">
                        <el-input v-model="info.defaultValue" />
                    </kv>
                    <kv label="数组">
                        <selector v-model="info.isList" :data="{true:'是',false:'否','':'全部'}" />
                    </kv>
                    <kv label="必填">
                        <selector v-model="info.required" :data="{true:'是',false:'否','':'全部'}" />
                    </kv>
                    <kv label="备注">
                        <el-input v-model="info.remark" type="textarea"/>
                    </kv>
                </el-card>
            </el-col>

        </el-row>
    </div>
</template>

<script setup>
/**
 * Created by CodeGenerator  at 2023-11-05 12:25:36
 */
import RefObjectReference
    from
        "@/component/empty-ref"




defineOptions({
    name: "ref-api-body-parameter-define",
    inheritAttrs: true,
});

//定义 vue2的this,当前组件
const $self = getCurrentInstance();

//定义 $attrs
const $attrs = useAttrs();



//定义data
const $data = reactive({
    info: {
        items: [],
        enumData: [],
        objectReference: {},
    }, //子对象需要声明。
    ApiParameterTypeEnum: jv.enum.ApiParameterTypeEnum.getData(),
    ApiParameterStringTypeEnum: jv.enum.ApiParameterStringTypeEnum.getData(),
    ApiJsonLocationEnum: jv.enum.ApiJsonLocationEnum.getData(),
});
const info = $computed(()=> $data.info );

const $props = defineProps({
    id: { type: String } ,
    action: { type: String } ,
    title : { type: String }
});

const action_name = $computed(()=>{
    return {add: "添加", edit: "修改"}[$props.action]
});
const $model = defineModel({ type: Object });



const list = ref();

//定义事件
const $emit = defineEmits(["update:modelValue","loaded"]);



watch($model, function(v) {
    if( $data.info == v) return;
    $data.info = v;
} ,{ immediate:true });
watch(info, function(v) {
    if( $data.info == v) return;
    $emit("update:modelValue",v)
} ,{ immediate:true });

</script>

<style scoped lang="scss">
</style>